package com.project.common.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.common.entity.PageVo;
import com.project.common.entity.SysMenus;
import com.project.common.entity.SysUsers;
import com.project.common.mapper.SysMenusMapper;
import com.project.common.service.SysMenusService;
import com.project.xsf.entity.MManufacture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Service
public class SysMenusImpl implements SysMenusService {
    @Autowired
    private SysMenusMapper sysMenusMapper;
    @Override
    public List<SysMenus> queryMenu(Integer userId) {
        return sysMenusMapper.queryMenu(userId);
    }

    @Override
    public SysMenus selectByPrimaryKey(Integer id) {
        return sysMenusMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageVo<SysMenus> queryAllMenus(Map<String, String> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));
//        System.out.println(map);
        PageHelper.startPage(pageNum,pageSize);
        List<SysMenus> sysMenus = sysMenusMapper.queryAllMenus();

        PageInfo<SysMenus> pageInfo = new PageInfo<SysMenus>(sysMenus);

        PageVo<SysMenus> pageVo = new PageVo<SysMenus>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public List<SysMenus> queryAllMenus() {
        return sysMenusMapper.queryAllMenus();
    }

    @Override
    public List<SysMenus> queryMenusByRoleId(Integer roleId) {
        List<SysMenus> sysMenus = sysMenusMapper.queryMenusByRoleId(roleId);
        return sysMenus;
    }


}
